
#########################################################################
README
Media Influence and Spatial Voting: The Role of Perceived Party Positions
Political Behavior
Lucas Paulo da Silva
28/02/2025
#########################################################################





########## INTRODUCTION ########## 
This README file describes how to use the datasets and code contained in the replication data for 
"Media Influence and Spatial Voting: The Role of Perceived Party Positions." This research paper 
is being published at Political Behavior. The replication data can be found at the Political 
Behavior Dataverse: https://doi.org/10.7910/DVN/MJIF4M

I have tried to make the replication process as quick and easy as possible. The three code files
require only a few changes in order to run. All figures, tables, and statistics from the main 
research paper and the supplementary material (Appendices A-G) can be replicated using the 
following materials:
	- Foos and Bischof (FB) (2022) datasets - included in the replication data
	- British Social Attitudes (BSA) datasets - see URLs below to download
	- prepare_dataset.do - merges the FB and BSA datasets, recodes variables, and prepares the 
	  main dataset used for analysis
	- analysis.R - creates the figures, tables, and statistics used in the main research paper
	- appendices.R - creates the figures, tables, and statistics used in the appendices

This study benefits greatly from Foos and Bischof (2022), which first identified the quasi-
experimental treatment. It also uses much of the same original data and similar code in 
prepare_dataset.do. The differences include different outcome variables, statistical models, 
control variables, and the coding of variables. The research paper and replication data for Foos 
and Bischof (2022) can be found here:
https://doi.org/10.1017/S000305542100085X (research paper)
https://doi.org/10.7910/DVN/NYPOQD (replication data)





########## DATA ########## 

### FB ### 
This study uses five datasets that are created with the code from Foos and Bischof (2022). For
your convenience, I have already created these datasets and include them in the replication
data. They are as follows:
	- 1993_postcodes.dta
	- 1997_constituencies_RA_checks.xlsx
	- 1997_postcodes.xlsx
	- 1999_postcodes.xlsx
	- FB_nuts2.dta

These are used in prepare_dataset.do.



### BSA ### 
Most of the data comes from 14 BSA datasets that include individual-level BSA survey data from the 
UK between 1983-2004. With the exception of the 1983-1991 merge file and 1988 (when the survey was 
not conducted), each year has its own dataset. I am not permitted to upload BSA data or recoded 
versions of the data. To obtain it, you can download the individual datasets from the UK Data 
Service at: https://beta.ukdataservice.ac.uk/datacatalogue/series/series?id=200006

Below are the URLs for each individual dataset:
	- 1983-1991 merge - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=2955
	- 1992 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=2981
	- 1993 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=3439
	- 1994 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=3572
	- 1995 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=3764
	- 1996 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=3921
	- 1997 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=4072
	- 1998 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=4131
	- 1999 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=4318
	- 2000 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=4486
	- 2001 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=4615
	- 2002 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=4838
	- 2003 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=5235
	- 2004 - https://beta.ukdataservice.ac.uk/datacatalogue/studies/study?id=5329

These should generally be named "bsa" along with the two-digit year number. For example, the 1993
dataset should already be named "bsa93". The exceptions are as follows:
	- 1983-1991 merge - "bsa83-91_2955.dta"
	- 1992 - "bsa92_bes92e.dta"
	- 1996 - "bsa96_g921au.dta"
	- 1997 - "bsa97a.dta"
	- 1998 - "bsa98a.dta"
	- 1999 - "bsa99a.dta"

If they do not have these names, then you should change them accordingly. This will ensure that 
they match the names in prepare_dataset.do. All of these files are Stata Datasets (.dta).



### File structure ###
The easiest way to replicate this study is to save all of the FB and BSA datasets into one folder.
The file path for this folder can then be used in the code below. 





########## CODE ########## 

### prepare_dataset.do ###
Once you have the data, open prepare_dataset.do in Stata. If you have put all the datasets into 
one folder, you can use CNTRL+H to replace all instances of the placeholder file path 
"C:\your\path\to\" with your folder's filepath. For example, if your folder is 
"C:\Jane\OneDrive\replication_of_amazing_study\", then the first line of code in prepare_dataset.do 
would change from...

	use "C:\your\path\to\bsa83-91_2955.dta", clear

...to...

	use "C:\Jane\OneDrive\replication_of_amazing_study\bsa83-91_2955.dta", clear

This will also save new datasets created by prepare_dataset.do in the same folder. You should be 
able to run all of the code with just this filepath change, as long as you have all the FB and BSA 
datasets correctly in the folder. If you prefer to organize your datasets into different folders,
it will simply require a bit more work to go through the do-file and change the filepaths
accordingly. In the end, prepare_dataset.do creates and saves FB_BSA.dta, which is the only 
file necessary for analysis.R and appendices.R. It also creates and saves five other files as 
Stata Datasets that are used within prepare_dataset.do:
	- 1997_postcodes.dta
	- 1997_constituencies_ready.dta
	- 1999_postcodes.dta
	- BSA_merge.dta
	- FB_timeseries.dta



### analysis.R ###
After creating FB_BSA.dta, open analysis.R in R. Install any of the R packages (lines 16-42) that 
you do not already have installed. Set the working directory to the folder where you saved 
FB_BSA.dta. If you do not mind saving plots to this same folder, you can already run all of the 
code. If you wish to save plots elsewhere, you can change the working directory after loading
FB_BSA.dta (for example, in line 56). Of course, if you wish to save plots in several folders,
you will need to reset the working directory or specify the filepaths accordingly.



### appendices.R ###
This RScript works very similarly to analysis.R. You do not have to run analysis.R before running
appendices.R. Open appendices.R in R. Install any of the R packages (lines 17-41) that 
you do not already have installed. Set the working directory to the folder where you saved 
FB_BSA.dta. If you do not mind saving plots to this same folder, you can already run all of the 
code. If you wish to save plots elsewhere, you can change the working directory after loading
FB_BSA.dta (for example, in line 55). Of course, if you wish to save plots in several folders,
you will need to reset the working directory or specify the filepaths accordingly.





########## CONCLUSION ##########
This is all that is needed to replicate the study. Please feel free to contact me (Lucas da Silva) 
at lpdasilva3@gmail.com if you have any questions, feedback, or concerns.


